<?php

namespace app\controller\car;

use app\BaseController;
use think\response\Json;

class Driver extends BaseController
{
    public function save(): Json
    {
        return $this->handle(function () {
            return $this->app->make(\app\model\User::class)->addDriver();
        });
    }

    public function number(): Json
    {
        return $this->handle(function () {
            return $this->app->make(\app\model\User::class)->queryDriver();
        });
    }

    public function lst(): Json
    {
        return $this->handle(function () {
            return $this->app->make(\app\model\User::class)->lst();
        });
    }

    public function download(): Json
    {
        return $this->handle(function () {
            return $this->app->make(\app\model\User::class)->download();
        });
    }

    public function updateState(): Json
    {
        return $this->handle(function () {
            $param = $this->request->post();
            $this->app->make(\app\model\User::class)->whereIn('id', $param['ids'])->update(['state' => $param['state']]);
            return $param;
        });
    }

    public function recharge()
    {
        return $this->handle(function () {
            return $this->app->make(\app\model\User::class)->addDriverBalance();
        });
    }
}
